#define DEBUG
#include <cstdio>
#define MAXN 100000
#define MAXM 100000

using namespace std;

int main() {
#ifdef DEBUG
  freopen("4673.in", "r", stdin);
  freopen("4673.out", "w", stdout);
#endif

  static char s[MAXN+2];
  int n, m;
  scanf("%d %d", &n, &m);
  scanf("%s", s+1);

  int cnt=1;
  for (int i=2; i<=n; i++) {
    if (s[i]!=s[i-1]) {
      cnt++;
    }
  }
  long long ans=(long long)cnt*n*(m-1);

  for (int i=2, len=1; i<=n+1; i++, len++) {
    if (s[i]!=s[i-2] || s[i]==s[i-1]) {
      ans = ans-len*(len-1)/2;
      if (s[i]==s[i-1]) {
	len=0;
      } else {
	len=1;
      }
    }
  }

  printf("%lld", ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
